﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AOC19NET.Controls {
	/// <summary>
	/// Interaction logic for VerticalBarGraph.xaml
	/// </summary>
	public partial class VerticalBarGraph : UserControl {
		/// <summary>
		/// Default constructor.
		/// </summary>
		public VerticalBarGraph() {
			InitializeComponent();
		}

		/// <summary>
		/// Sets the value of the bar.
		/// </summary>
		/// <param name="_fNewValue">The new value. Must be a percentage within the range [0..1].</param>
		public void SetValue(float _fNewValue) {
			m_BarForeground.Height = m_BarBackground.ActualHeight * _fNewValue;
		}

		#region LABEL PROPERTY
		/// <summary>
		/// "Label" property accessor.
		/// </summary>
		public String Label {
			get { return (String)GetValue(LabelProperty); }
			set { SetValue(LabelProperty, (String)value); }
		}

		/// <summary>
		/// "Label" property definition and registration.
		/// </summary>
		public static DependencyProperty LabelProperty =
				DependencyProperty.Register(
				"LabelProperty", typeof(String), typeof(VerticalBarGraph),
				new PropertyMetadata("",
					new PropertyChangedCallback(LabelPropertyChangedCallback)
				)
			);

		/// <summary>
		/// "Label" property change callback.
		/// </summary>
		/// <param name="_Sender">Event sender</param>
		/// <param name="_Arguments">Event arguments.</param>
		public static void LabelPropertyChangedCallback(DependencyObject _Sender, DependencyPropertyChangedEventArgs _Arguments) {
			VerticalBarGraph Sender = (VerticalBarGraph)_Sender;
			Sender.m_Label.Content = (String)_Arguments.NewValue;
		}
		#endregion

		#region LABEL COLOR PROPERTY
		/// <summary>
		/// "LabelColor" property accessor.
		/// </summary>
		public Brush LabelColor {
			get {
				return (Brush)GetValue(LabelColorProperty);
			}
			set {
				SetValue(LabelColorProperty, (Brush)value);
			}
		}

		/// <summary>
		/// "LabelColor" property definition and registration.
		/// </summary>
		public static DependencyProperty LabelColorProperty =
				DependencyProperty.Register(
				"LabelColorProperty", typeof(Brush), typeof(VerticalBarGraph),
				new PropertyMetadata(Brushes.Black,
					new PropertyChangedCallback(LabelColorPropertyChangedCallback)
				)
			);

		/// <summary>
		/// "LabelColor" property change callback.
		/// </summary>
		/// <param name="_Sender">Event sender</param>
		/// <param name="_Arguments">Event arguments.</param>
		public static void LabelColorPropertyChangedCallback(DependencyObject _Sender, DependencyPropertyChangedEventArgs _Arguments) {
			VerticalBarGraph Sender = (VerticalBarGraph)_Sender;
			Sender.m_Label.Foreground = (Brush)_Arguments.NewValue;
		}
		#endregion

		#region BAR BACKGROUND COLOR PROPERTY
		/// <summary>
		/// "BarBackgroundColor" property accessor.
		/// </summary>
		public Brush BarBackgroundColor {
			get {
				return (Brush)GetValue(BarBackgroundColorProperty);
			}
			set {
				SetValue(BarBackgroundColorProperty, (Brush)value);
			}
		}

		/// <summary>
		/// "BarBackgroundColor" property definition and registration.
		/// </summary>
		public static DependencyProperty BarBackgroundColorProperty =
				DependencyProperty.Register(
				"BarBackgroundColorProperty", typeof(Brush), typeof(VerticalBarGraph),
				new PropertyMetadata(Brushes.DarkGray,
					new PropertyChangedCallback(BarBackgroundColorPropertyChangedCallback)
				)
			);

		/// <summary>
		/// "BarBackgroundColor" property change callback.
		/// </summary>
		/// <param name="_Sender">Event sender</param>
		/// <param name="_Arguments">Event arguments.</param>
		public static void BarBackgroundColorPropertyChangedCallback(DependencyObject _Sender, DependencyPropertyChangedEventArgs _Arguments) {
			VerticalBarGraph Sender = (VerticalBarGraph)_Sender;
			Sender.m_BarBackground.Fill = (Brush)_Arguments.NewValue;
		}
		#endregion

		#region BAR FOREGROUND COLOR PROPERTY
		/// <summary>
		/// "BarForegroundColor" property accessor.
		/// </summary>
		public Brush BarForegroundColor {
			get {
				return (Brush)GetValue(BarForegroundColorProperty);
			}
			set {
				SetValue(BarForegroundColorProperty, (Brush)value);
			}
		}

		/// <summary>
		/// "BarForegroundColor" property definition and registration.
		/// </summary>
		public static DependencyProperty BarForegroundColorProperty =
				DependencyProperty.Register(
				"BarForegroundColorProperty", typeof(Brush), typeof(VerticalBarGraph),
				new PropertyMetadata(Brushes.LightGray,
					new PropertyChangedCallback(BarForegroundColorPropertyChangedCallback)
				)
			);

		/// <summary>
		/// "BarForegroundColor" property change callback.
		/// </summary>
		/// <param name="_Sender">Event sender</param>
		/// <param name="_Arguments">Event arguments.</param>
		public static void BarForegroundColorPropertyChangedCallback(DependencyObject _Sender, DependencyPropertyChangedEventArgs _Arguments) {
			VerticalBarGraph Sender = (VerticalBarGraph)_Sender;
			Sender.m_BarForeground.Fill = (Brush)_Arguments.NewValue;
		}
		#endregion
	}
}
